from public.pages import BasePage
from Data.ElementData import baiduElement
from selenium import webdriver
from time import sleep
import json

driver = webdriver.Chrome()
driver.maximize_window()
driver.get('https://hitokoto.cn/')
sleep(2)
driver.find_element_by_xpath("//button[contains(text(),'拒绝')]").click()
sleep(1)
driver.find_element_by_xpath("//div[@class='mdl-layout__header-row']//a[@class='mdl-navigation__link'][contains(text(),'登录')]").click()
driver.find_element_by_xpath("//input[@id='input-40']").send_keys('1069221287@qq.com')
driver.find_element_by_xpath("//input[@id='input-43']").send_keys('111069221287')
driver.find_element_by_xpath("//span[contains(text(),'登录')]")
sleep(3)
listcookie= driver.get_cookies()
dictcookie = json.dumps(listcookie)
# print(cookie)
# print(b)
driver.quit()
driver = webdriver.Chrome()
driver.delete_all_cookies()
for c in dictcookie :
    driver.add_cookie(c)
driver.get('https://hitokoto.cn/')
sleep(5)
driver.close()
# elem = driver.find_element_by_id('kw')
# elem.send_keys('hello world')
# elem.submit()
# sleep(3)
# driver.close()
